define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function(){
		this.callParent();
	};

	Model.prototype.backBtnClick = function(event){

		this.comp("wing1").showLeft();
	};

	Model.prototype.treeViewDataIndexChanged = function(event){
		if(event.row.val("fTableName") == "equip_table"){
			this.comp("dataSelection").setValue("id", event.row.val("fNodeId"));
			var id = event.row.val("fNodeId");
			this.comp("mainData").setFilter('filter0', "fEquipID = '" + id + "'" );
			this.comp("mainData").refreshData();
		}
	};

	Model.prototype.listRowClick = function(event){

		this.comp("windowDialogCurve").open({
			"data":{
				"pointID" : event.bindingContext.$object.val("fID"), 
				"table":"visual_data_table",
				"pointName" : event.bindingContext.$object.val("fPointName"),
				"pointUnit" : event.bindingContext.$object.val("fUnit")
			}
		});
	};

	/*Model.prototype.modelLoad = function(event){
		var rows = this.comp("treeViewData").find("fTableName", "equip_table", true);
		if(rows.length > 0){
			this.comp("treeViewData").to(rows[0]);
		}
	};*/

	Model.prototype.treeViewDataCreate = function(event){

		event.source.getTreeOption().rootFilter = "fNodeId='" + localStorage.getItem("username") + "'";
		this.comp("mainData").setFilter('filter0', "1=0");
	};

	return Model;
});